package flc.ast.adapter;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

import flc.ast.R;
import flc.ast.bean.PictureClsBean;
import flc.ast.bean.PictureClsBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;

public class PictureClsAdapter extends StkProviderMultiAdapter<PictureClsBean> {


    public PictureClsAdapter() {
        addItemProvider(new PictureClsItemProvider());
    }

    private class PictureClsItemProvider extends BaseItemProvider<PictureClsBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_picture_cls;
        }

        @Override
        public void convert(@NotNull BaseViewHolder baseViewHolder, PictureClsBean bean) {
            baseViewHolder.setText(R.id.tvPictureClsTitle, bean.getTitle());
            baseViewHolder.setText(R.id.tvPictureClsSize, context.getString(R.string.cls_project_size, bean.getImageList().size()));

            RecyclerView rvPictureChild = baseViewHolder.getView(R.id.rvPictureChild);
            rvPictureChild.setLayoutManager(new GridLayoutManager(getContext(), 3));
            PictureChildAdapter pictureChildAdapter = new PictureChildAdapter();
            rvPictureChild.setAdapter(pictureChildAdapter);
            pictureChildAdapter.setList(bean.getImageList());
            pictureChildAdapter.setOnItemClickListener(getOnItemClickListener());
        }
    }
}
